home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / ASTRNOMY / AA_51.ZIP / LONLAT.C < prev    next >
C/C++ Source or Header  |  1993-02-13  |  914b  |  57 lines

  1.  
  2. /* Display ecliptic longitude and latitude for
  3.  * equinox of date.  Input is equatorial rectangular
  4.  * coordinates for equinox J2000.
  5.  */
  6.  
  7. #include "kep.h"
  8.  
  9. int lonlat( pp, J, polar )
  10. double pp[], J, polar[];
  11. {
  12. double s[3], x, y, z, yy, zz, r;
  13. int i;
  14.  
  15. /* Make local copy of position vector
  16.  * and calculate radius.
  17.  */
  18. r = 0.0;
  19. for( i=0; i<3; i++ )
  20.     {
  21.     x = pp[i];
  22.     s[i] = x;
  23.     r += x * x;
  24.     }
  25. r = sqrt(r);
  26.  
  27. /* Precess to equinox of date J
  28.  */
  29. precess( s, J, -1 );
  30.  
  31. /* Convert from equatorial to ecliptic coordinates
  32.  */
  33. epsiln(J);
  34. yy = s[1];
  35. zz = s[2];
  36. x  = s[0];
  37. y  =  coseps * yy  +  sineps * zz;
  38. z  = -sineps * yy  +  coseps * zz;
  39.  
  40. yy = zatan2( x, y );
  41. zz = asin( z/r );
  42.  
  43. polar[0] = yy;
  44. polar[1] = zz;
  45. polar[2] = r;
  46.  
  47. if( prtflg == 0 )
  48.     return(0);
  49.  
  50. printf( "ecliptic long" );
  51. dms( yy );
  52. printf( " lat" );
  53. dms( zz );
  54. printf( " rad %.6E\n", r );
  55. return(0);
  56. }
  57.